<template>
    <div class="check">
        <div class="search">
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="查询时间">
                    <el-col :span="11">
                        <el-date-picker type="date" placeholder="选择日期" v-model="formInline.date1"
                            class="inputtime"></el-date-picker>
                    </el-col>
                </el-form-item>
                <el-form-item>
                </el-form-item>
                <el-form-item>
                </el-form-item>
                <el-form-item class="search_but">
                    <el-button style="background-color: #3768FA; color: white;" type="primary"
                        @click="onSubmit">查询</el-button>
                    <el-button style=" background-color: #3768FA1a; color: #3768FA; border:1px solid #3768FA;"
                        type="primary" @click="onSubmit">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="list">
            <div class="list_feature">
                <div class="new_tab">
                    <el-button-group>
                        <el-button type="primary">删除</el-button>
                    </el-button-group>
                    <p class="parting"></p>
                    <el-button-group>
                        <el-button type="primary">导入数据</el-button>
                    </el-button-group>
                    <el-button-group>
                        <el-button type="primary" @click="showChildDialog">导出数据</el-button>
                    </el-button-group>
                    <el-button-group>
                        <el-button type="primary">数据清理</el-button>
                    </el-button-group>
                </div>
                <p class="tab">表格设置 </p>
            </div>
            <div class="list_count">

                <template>
                    <el-table :data="list" fit border style="width: 100%" height="100%">
                        <el-table-column type="selection" width="55">
                        </el-table-column>
                        <el-table-column prop="index" label="序号" width="180">
                        </el-table-column>
                        <el-table-column prop="id" label="业主编号" width="180">
                        </el-table-column>
                        <el-table-column prop="proprietor" label="业主名称">
                        </el-table-column>
                        <el-table-column prop="address" label="表计地址">
                        </el-table-column>
                        <el-table-column prop="basic_cost" label="基本费用">
                        </el-table-column>
                        <el-table-column prop="time_frame" label="时段名称">
                        </el-table-column>
                        <el-table-column prop="previous" label="上期读数">
                        </el-table-column>
                        <el-table-column prop="current" label="本期用量">
                        </el-table-column>
                        <el-table-column prop="unit_price" label="计量单价">
                        </el-table-column>
                        <el-table-column prop="use_expense" label="使用费用">
                        </el-table-column>
                        <el-table-column prop="total_cost" label="总费用">
                        </el-table-column>
                        <el-table-column prop="display_time" label="缴费期间">
                        </el-table-column>
                        <el-table-column fixed="right" label="操作" width="100">
                            <template slot-scope="scope">
                                <el-button style="color: #3768FA;" @click="handleClick(scope.row)" type="text"
                                    size="small">编辑</el-button>
                                <el-button style="color: #F8544B;" type="text" size="small">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </template>
            </div>
            <div class="Pagination">
                <template>
                    <div class="block">
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page="currentPage" :page-sizes="[100, 200, 300, 400]" :page-size="100"
                            layout="total, sizes, prev, pager, next, jumper" :total="400">
                        </el-pagination>
                    </div>
                </template>
            </div>
        </div>

        <!-- 导出数据弹窗 -->
        <Drawer ref="drawerComponent" :title="drawerTitle">
            <el-form ref="form" :model="form" label-width="80px">
                <div class="drawer_count">
                    <el-radio-group v-model="form.resource">
                        <el-radio label="按时间">
                        </el-radio>
                        <el-form-item label="活动时间">
                            <el-col :span="11">
                                <el-date-picker type="date" placeholder="选择日期" v-model="form.date1"
                                    style="width: 100%;"></el-date-picker>
                            </el-col>
                            <el-col class="line" :span="2">-</el-col>
                            <el-col :span="11">
                                <el-time-picker placeholder="选择时间" v-model="form.date2"
                                    style="width: 100%;"></el-time-picker>
                            </el-col>
                        </el-form-item>
                        <el-radio label="全部"></el-radio>
                    </el-radio-group>
                </div>
            </el-form>
        </Drawer>
        <!-- 编辑弹窗 -->
        <Drawer ref="redact" :title="redactTitle">
            <el-form ref="form" :model="row_ov" label-width="80px">
                <el-form-item label="业主编号">
                    <el-input v-model="row_ov.id"></el-input>
                </el-form-item>
                <el-form-item label="业主名称">
                    <el-input v-model="row_ov.proprietor"></el-input>
                </el-form-item>
                <el-form-item label="表计地址">
                    <el-input v-model="row_ov.address"></el-input>
                </el-form-item>
                <el-form-item label="基本费用">
                    <el-input v-model="row_ov.basic_cost"></el-input>
                </el-form-item>
                <el-form-item label="时段名称">
                    <el-input v-model="row_ov.time_frame"></el-input>
                </el-form-item>
                <el-form-item label="上期读数">
                    <el-input v-model="row_ov.previous"></el-input>
                </el-form-item>
                <el-form-item label="本期用量">
                    <el-input v-model="row_ov.current"></el-input>
                </el-form-item>
                <el-form-item label="计量单价">
                    <el-input v-model="row_ov.unit_price"></el-input>
                </el-form-item>
                <el-form-item label="使用费用">
                    <el-input v-model="row_ov.use_expense"></el-input>
                </el-form-item>
                <el-form-item label="总费用">
                    <el-input v-model="row_ov.total_cost"></el-input>
                </el-form-item>
            </el-form>
        </Drawer>



    </div>
</template>
<script>
import { getList } from '@/api/check'
export default {
    name: 'Check',
    data() {
        return {
            formInline: {
                user: '',
                region: '',
                date1: '',
                date2: '',
            },
            form: {
                region: '',
                date1: '',
                date2: '',
            },
            list: null,
            listLoading: true,
            currentPage: 4,
            row_ov:{},
            redactTitle: '编辑',
            drawerTitle: "导出数据",
        };
    },
    created() {
        // 获取mock数据
        this.fetchData()

    },
    methods: {
        handleClick(tab, event) {
            console.log(tab, event);
            this.row_ov=tab;
            this.$refs.redact.openDrawer()
        },
        onSubmit() {
            console.log('submit!');
        },
        handleClicktab(row) {
            console.log(row);
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
        },
        // 处理mock数据
        fetchData() {
            this.listLoading = true
            getList().then(response => {
                this.list = response.data.data.items
                this.listLoading = false
                console.log(this.list[0])
            })
        },
           // 弹窗点击事件
           showChildDialog() {
            // 通过 ref 获取子组件实例并调用 openDrawer 方法
            this.$refs.drawerComponent.openDrawer();
        },
    }
};
</script>

<!-- <style lang="scss">
.el-tabs__header {
    margin: 0;

}

.el-tabs__content {
    width: 100%;
    height: 100%;
    background-color: #F0F3FA;
}

.el-tabs__nav-scroll {
    height: 60px;
    line-height: 60px;
    margin-left: 20px;
}

.el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #c0c4cc;
}
</style>-->
<style lang="scss" scoped >
// .alarmWay {
//     width: 100%;
//     height: 100%;

//     .el-tabs {
//         width: 100%;
//         height: 100%;
//     }
// } 

// .el-form {
//     white-space: nowrap
// }

.check {
    width: calc(100% - 30px);
    height: calc(100vh - 130px);
    margin: 0 auto;
display: flex;
flex-direction: column;

    .search {
        width: 100%;
        background-color: white;
        border-radius: 4px;
        margin-top: 15px;

        .el-form {
            // margin:  0;
            width: calc(100% - 40px);
            margin: 0 auto;
            padding: 10px 0;
            display: flex;
            flex-wrap: wrap;

            .el-form-item {
                margin: 5px 30px 5px 0;
            }

            .search_but {
                width: 200px;
                margin-right: 0;
                margin-left: auto;
            }
        }
    }

    .list {
        width: 100%;
        height: calc(100% - 100px);
        margin-top: 10px;
        background-color: white;
        border-radius: 4px;
        flex-grow: 1;
        margin-bottom: 15px;

        .list_feature {
            width: calc(100% - 30px);
            margin: 0 auto;
            height: 70px;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .new_tab {
                display: flex;
                align-items: center;

                .el-button-group {
                    margin-right: 10px;
                }

                .parting {
                    margin: 0 10px 0 0;
                    width: 1px;
                    height: 20px;
                    background-color: #dadada;
                }

                .el-button {
                    background-color: transparent;
                    color: #666;
                    border: 1px solid #DADADA;
                    border-radius: 4px;
                }

                .el-button:hover {
                    background-color: #3768FA1a;
                    color: #3768FA ;
                    border: 1px solid #3768FA;
                    border-radius: 4px;
                }
            }

            .tab {
                color: #999;
                cursor: pointer;
                font-size: 14px;
            }
        }

        .list_count {
            width: calc(100% - 30px);
            height: calc(100% - 170px);
            margin: 0 auto;
            overflow: auto;
        }

        .Pagination {
            width: calc(100% - 30px);
            margin: 30px auto 0 auto;

            .block {
                float: right;
            }
        }


    }
    .drawer_count {
        .el-radio-group {
            display: flex;
            flex-direction: column;

            .el-form-item {
                margin-top: 22px;

                // .el-select {
                //     width: 100%;
                // }
            }
        }
    }
}
</style>
  